local ligai = fk.CreateSkill {
  name = "lingling__ligai",
}

ligai:addEffect(fk.CardUseFinished, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(ligai.name) and
      data.card and not data.card.multiple_targets and data.card.type == Card.TypeTrick then
      local tos = data:getAllTargets()
      if #tos == 1 then
        return tos[1] ~= player
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local to = data:getAllTargets()[1]
    if player.room:askToSkillInvoke(player, { skill_name = ligai.name, prompt = "#lingling__ligai-invoke::" .. to.id }) then
      event:setCostData(self, { tos = { to } })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local card = data.card
    local to = event:getCostData(self).tos[1] ---@type ServerPlayer
    room:damage{
      from = player,
      to = to,
      damage = 1,
      skillName = ligai.name
    }
    if to.dead then return end
    room:obtainCard(to, card, nil, fk.ReasonPrey, to, ligai.name)
    if to:getHandcardNum() > player:getHandcardNum() and player:isAlive() then
      player:drawCards(1, ligai.name)
    end
  end,
})

Fk:loadTranslationTable{
  ["lingling__ligai"] = "厉改",
  [":lingling__ligai"] = "当你对其他角色使用单目标锦囊牌结算后，你可以对唯一目标造成1点伤害，其获得此牌，然后若其手牌多于你，你摸一张牌。",

  ["#lingling__ligai-invoke"] = "厉改：你可以对 %dest 造成1点伤害，其获得此牌，然后若其手牌多于你，你摸一张牌。",
}

return ligai